﻿using System.Web.Mvc;
using SimpleServiceBus.EndpointManagement.Wcf.Contracts.Data;

namespace SimpleServiceBus.EndpointMonitor.Web.Helpers
{
    public static class SsbUrlHelperExtensions
    {
        public static string EndpointLink(this UrlHelper url,ManagedEndpointContract endpoint)
        {
            return url.Content("~/Endpoints/" + endpoint.EndpointID);
        }
        public static string EndpointErrorLink(this UrlHelper url, EndpointErrorContract error)
        {
            return url.Content("~/Endpoints/" + error.ManagedEndpoint.EndpointID + "/Errors/" + error.Id);
        }

        public static string Image(this UrlHelper url,string imageName)
        {
            return url.Content("~/Content/Images/" + imageName);
        }

        public static string EndpointImage(this UrlHelper url,ManagedEndpointContract endpoint)
        {
            if (endpoint == null)
                return string.Empty;

            string imageName = "bullet_ball_glass_green.png";
            if (endpoint.Status == "Offline")
                imageName = "bullet_ball_glass_gray.png";
            else if (endpoint.Status == "Unknown")
                imageName = "bullet_ball_glass_red.png";

            return url.Image(imageName);
        }
    }
}
